<?#//v.3.1.2

#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

include "../includes/config.inc.php";
include "loggedin.inc.php";
include $include_path."countries.inc.php";

$username = $name;
//-- Data check

if(!$_REQUEST['id']){
    header("Location: listusers.php");
    exit;
}

if($_POST['action']=='Delete'){
    if($_POST['mode'] == "activate") {
        $sql="update PHPAUCTIONXL_users set suspended=0,reg_date=reg_date WHERE id='$_POST[idhidden]'";
        /* Update column users in table PHPAUCTIONXL_counters */
        $counteruser = mysql_query("UPDATE PHPAUCTIONXL_counters SET inactiveusers=(inactiveusers-1), users=(users+1)");
    } else {
        $sql="update PHPAUCTIONXL_users set suspended=1,reg_date=reg_date WHERE id='$_POST[idhidden]'";

        /* Update column users in table PHPAUCTIONXL_counters */
        $counteruser = mysql_query("UPDATE PHPAUCTIONXL_counters SET inactiveusers=(inactiveusers+1), users=(users-1)");
    }
    $res=mysql_query ($sql);
    
    Header("Location: listusers.php");
    exit;
}

if(!$action || ($action && $updated)) {
    
    $query = "select * from PHPAUCTIONXL_users where id='".$_GET['id']."'";
    $result = mysql_query($query);
    if(!$result){
        print "Database access error: abnormal termination".mysql_error();
        exit;
    }

    $username = mysql_result($result,0,"name");
    $nick = mysql_result($result,0,"nick");
    $password = mysql_result($result,0,"password");
    $email = mysql_result($result,0,"email");
    $address = mysql_result($result,0,"address");
    $country = mysql_result($result,0,"country");
    $country_list="";
    while (list ($code, $descr) = each ($countries)) {
        $country_list .= "<option value=\"$descr\"";
        if ($descr == $country) {
            $country_list .= " selected";
        }
        $country_list .= ">$descr</option>\n";
    }
    
    $prov = mysql_result($result,0,"prov");
    $zip = mysql_result($result,0,"zip");
    $birthdate = mysql_result($result,0,"birthdate");
    $birth_day = substr($birthdate,6,2);
    $birth_month = substr($birthdate,4,2);
    $birth_year = substr($birthdate,0,4);
    $birthdate = "$birth_day/$birth_month/$birth_year";
    $phone = mysql_result($result,0,"phone");
    $suspended = mysql_result($result,0,"suspended");
    $rate_num = mysql_result($result,0,"rate_num");
    $rate_sum = mysql_result($result,0,"rate_sum");
    if ($rate_num) {
        $rate = round($rate_sum / $rate_num);
    } else {
        $rate=0;
    }
}
?>
<HTML> 
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<STYLE TYPE="text/css">
body {
scrollbar-face-color: #aaaaaa;
scrollbar-shadow-color: #666666;
scrollbar-highlight-color: #aaaaaa;
scrollbar-3dlight-color: #dddddd;
scrollbar-darkshadow-color: #444444;
scrollbar-track-color: #cccccc;
scrollbar-arrow-color: #ffffff;
}</STYLE>
<link href="css/main.css" rel="stylesheet" type="text/css">
</HEAD>
<bodyleftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titulo">
        <tr> 
          <td class="icono"><img src="images/users_icon2.gif" width="17" height="23" ></td>
          <td class="breadcrumbs"><p><span><?=$MSG_25_0010?></span>&nbsp;&gt;&gt;&nbsp;<?=$MSG_045?></p></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
    <tr> 
    <td align="center" valign="middle">
<BR>
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="CENTER" class="base" style="border:1px solid #ccc;">
        <tr>
          <td align=CENTER class=title>
            <p><?
            if($suspended > 0) {
                print $MSG_306;
            } else {
                print $MSG_305;
            }
        ?>
           </p></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><table width=100% celpadding=4 cellspacing=0 border=0>
            <?
                      if($updated){
                          print "<TR><TD></TD><TD WIDTH=486>";
                          if($updated) print "Users data updated";
                          print "</TD>
                    </TR>";
                      }
?>
            <tr>
              <td width="125" valign="top"class="lineV"><p class="blue"><? print "$MSG_302"; ?></p> </td>
              <td width="486"><?print $username; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV gris"><p class="blue"><? print "$MSG_003"; ?></p> </td>
              <td width="486" class="gris"><? print $nick; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV"><p class="blue"><? print "$MSG_004"; ?></p> </td>
              <td width="486"><? print $password; ?> </td>
            </tr>
            <tr>
              <td width="125"  valign="top"class="lineV gris"><p class="blue"><? print "$MSG_303"; ?></p> </td>
              <td width="486" class="gris"><? print $email; ?> </td>
            </tr>
            <tr>
              <td width="125"  valign="top"class="lineV"><p class="blue"><? print "$MSG_252"; ?></p> </td>
              <td width="486"><? print $birthdate; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV gris"><p class="blue"><? print "$MSG_009"; ?></p> </td>
              <td width="486" class="gris"><? print $address; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV"><p class="blue"><? print "$MSG_014"; ?></p> </td>
              <td width="486"><? print $country; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV gris"><p class="blue"><? print "$MSG_012"; ?> </p></td>
              <td width="486" class="gris"><? print $zip; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV"><p class="blue"><? print "$MSG_013"; ?> </p></td>
              <td width="486"><? print $phone; ?> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV gris"><p class="blue"><? print "$MSG_222"; ?></p> </td>
              <td width="486" class="gris"><? if(!$rate) $rate=0; ?>
                  <img src="../images/estrella_<? echo $rate; ?>.gif"> </td>
            </tr>
            <tr>
              <td width="125" valign="top"class="lineV"><p class="blue"><?
                          if($suspended > 0) {
                              print $MSG_310;
                          } else {
                              print $MSG_300;
                          }
                          ?>  </p>            </td>
              <td width="486"><?
                          if($suspended == 0)
                          print "$MSG_029";
                          else
                          print "$MSG_030";
                        ?>              </td>
            </tr>
            <tr>
              <td width="125">&nbsp;</td>
              <td width="486"><?
                          if($suspended > 0) {
                              print $MSG_309;
                              $mode = "activate";
                          } else {
                              print $MSG_308;
                              $mode = "suspend";
                          }
                          ?>              </td>
            </tr>
            <tr>
              <td width="125">&nbsp;</td>
              <td width="486"><form name=details action="excludeuser.php" method="POST">
                  <input type="hidden" name="id" value="<? echo $_GET['id']; ?>">
                  <input type="hidden" name="offset" value="<? echo $_GET['offset']; ?>">
                  <input type="hidden" name="action" value="Delete">
                  <input type="hidden" name="idhidden" value="<?=$_GET['id']?>">
                  <input type="hidden" name="mode" value="<? print $mode; ?>">
                  <input type="submit" name="act" value="<? print $MSG_030; ?>" class="action">
              </form></td>
            </tr>
          </table></td>
        </tr>
      </table>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>